<?php
/*
cmfit
Copyright (C) 2000-2007 Andreas Bengtsson

Email: anteman@users.sourceforge.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/
?>

<html>
    <head>
        <title>CMFIT - File listing</title>
    </head>
    <body>

    CMFIT [comfit] - ContentManagement - Flatfile,Injection and Templatedriven<BR>


 <?php

require('functions.php');
require('config.php');

if(isset($_GET['currdir'])){
 $currdir=$_GET['currdir'];
}

if(!isset($currdir)){
 //trace("Currdir not set, using default.");
 $currdir="";
}

// -------------------------------------------------------------
// -------------------------------------------------------------


echo "<A HREF=\"$c_liveurl\">Goto live system ...</A><BR><BR>\n";

$toptemplatedir=$c_templatedir;

// Are we browsing sub directories?
if(!empty($currdir)){
	$currdir=urldecode($currdir);
	$currdir=addseparator($currdir);
	$c_templatedir.=$currdir;
}

//echo ascdump($c_templatedir);

$handle=opendir($c_templatedir);
while ($file = readdir($handle)) {
	$thefile=$c_templatedir.$file;

	// up a directory unless at top
	if ( ($currdir!=$c_dirseparator)&&(substr($thefile,strlen($thefile)-2) == "..")){
		$oneup=$currdir;
		$oneup=substr($oneup,0,strrpos($oneup,$c_dirseparator));
		$oneup=substr($oneup,0,strrpos($oneup,$c_dirseparator));
	    echo "<A HREF=\"select.php?currdir=".urlencode($oneup)."\"><B>[UP]</B></A><BR>";
	}

     // if a directory
     if(is_dir($thefile)
	    && $file != "."
     	&& $file != ".."
        && $file != $c_bbstemplatedirname
        && (!ereg("_c$", $file))
     	){
     	echo "<A HREF=\"select.php?currdir=".urlencode($currdir).urlencode($file.$c_dirseparator)."\">$file <B>[DIR]</B></A> <BR>\n";
     }

     // make normal files process link
     if (
     (
     substr($thefile,strlen($thefile)-5) == ".html"
     ||
     substr($thefile,strlen($thefile)-5) == ".mall"
     )
     && $file != "."
     && $file != ".."
     && is_dir($thefile)==false
     ) {

         echo "<A HREF=\"editor.php?filename=".urlencode($file)."&currdir=".urlencode($currdir)."\">$file</A><BR>\n";


     }
 }
 closedir($handle);

 // -------------------------------------------------------------

 ?>



    </body>
</html>

